#[doc = "Register `control` reader"]
pub struct R(crate::R<CONTROL_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<CONTROL_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<CONTROL_SPEC>> for R {
    fn from(reader: crate::R<CONTROL_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `control` writer"]
pub struct W(crate::W<CONTROL_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<CONTROL_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::ops::DerefMut for W {
    #[inline(always)]
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
impl core::convert::From<crate::W<CONTROL_SPEC>> for W {
    fn from(writer: crate::W<CONTROL_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Timer lock control.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TIMER_LOCK_A {
    #[doc = "0: not locked."]
    UNLOCKED = 0,
    #[doc = "1: Locks the timer value to TIMER_CURRENTVALUE."]
    LOCKED = 1,
}
impl From<TIMER_LOCK_A> for bool {
    #[inline(always)]
    fn from(variant: TIMER_LOCK_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `timer_lock` reader - Timer lock control."]
pub struct TIMER_LOCK_R(crate::FieldReader<bool, TIMER_LOCK_A>);
impl TIMER_LOCK_R {
    pub(crate) fn new(bits: bool) -> Self {
        TIMER_LOCK_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> TIMER_LOCK_A {
        match self.bits {
            false => TIMER_LOCK_A::UNLOCKED,
            true => TIMER_LOCK_A::LOCKED,
        }
    }
    #[doc = "Checks if the value of the field is `UNLOCKED`"]
    #[inline(always)]
    pub fn is_unlocked(&self) -> bool {
        **self == TIMER_LOCK_A::UNLOCKED
    }
    #[doc = "Checks if the value of the field is `LOCKED`"]
    #[inline(always)]
    pub fn is_locked(&self) -> bool {
        **self == TIMER_LOCK_A::LOCKED
    }
}
impl core::ops::Deref for TIMER_LOCK_R {
    type Target = crate::FieldReader<bool, TIMER_LOCK_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `timer_lock` writer - Timer lock control."]
pub struct TIMER_LOCK_W<'a> {
    w: &'a mut W,
}
impl<'a> TIMER_LOCK_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: TIMER_LOCK_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "not locked."]
    #[inline(always)]
    pub fn unlocked(self) -> &'a mut W {
        self.variant(TIMER_LOCK_A::UNLOCKED)
    }
    #[doc = "Locks the timer value to TIMER_CURRENTVALUE."]
    #[inline(always)]
    pub fn locked(self) -> &'a mut W {
        self.variant(TIMER_LOCK_A::LOCKED)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
        self.w
    }
}
#[doc = "Timer interrupt mask.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TIMER_INT_MASK_A {
    #[doc = "0: not masked."]
    UNMASKED = 0,
    #[doc = "1: masked."]
    MASKED = 1,
}
impl From<TIMER_INT_MASK_A> for bool {
    #[inline(always)]
    fn from(variant: TIMER_INT_MASK_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `timer_int_mask` reader - Timer interrupt mask."]
pub struct TIMER_INT_MASK_R(crate::FieldReader<bool, TIMER_INT_MASK_A>);
impl TIMER_INT_MASK_R {
    pub(crate) fn new(bits: bool) -> Self {
        TIMER_INT_MASK_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> TIMER_INT_MASK_A {
        match self.bits {
            false => TIMER_INT_MASK_A::UNMASKED,
            true => TIMER_INT_MASK_A::MASKED,
        }
    }
    #[doc = "Checks if the value of the field is `UNMASKED`"]
    #[inline(always)]
    pub fn is_unmasked(&self) -> bool {
        **self == TIMER_INT_MASK_A::UNMASKED
    }
    #[doc = "Checks if the value of the field is `MASKED`"]
    #[inline(always)]
    pub fn is_masked(&self) -> bool {
        **self == TIMER_INT_MASK_A::MASKED
    }
}
impl core::ops::Deref for TIMER_INT_MASK_R {
    type Target = crate::FieldReader<bool, TIMER_INT_MASK_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `timer_int_mask` writer - Timer interrupt mask."]
pub struct TIMER_INT_MASK_W<'a> {
    w: &'a mut W,
}
impl<'a> TIMER_INT_MASK_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: TIMER_INT_MASK_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "not masked."]
    #[inline(always)]
    pub fn unmasked(self) -> &'a mut W {
        self.variant(TIMER_INT_MASK_A::UNMASKED)
    }
    #[doc = "masked."]
    #[inline(always)]
    pub fn masked(self) -> &'a mut W {
        self.variant(TIMER_INT_MASK_A::MASKED)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
        self.w
    }
}
#[doc = "Timer mode control\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TIMER_MODE_A {
    #[doc = "0: free mode."]
    FREE = 0,
    #[doc = "1: periodic mode"]
    PERIODIC = 1,
}
impl From<TIMER_MODE_A> for bool {
    #[inline(always)]
    fn from(variant: TIMER_MODE_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `timer_mode` reader - Timer mode control"]
pub struct TIMER_MODE_R(crate::FieldReader<bool, TIMER_MODE_A>);
impl TIMER_MODE_R {
    pub(crate) fn new(bits: bool) -> Self {
        TIMER_MODE_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> TIMER_MODE_A {
        match self.bits {
            false => TIMER_MODE_A::FREE,
            true => TIMER_MODE_A::PERIODIC,
        }
    }
    #[doc = "Checks if the value of the field is `FREE`"]
    #[inline(always)]
    pub fn is_free(&self) -> bool {
        **self == TIMER_MODE_A::FREE
    }
    #[doc = "Checks if the value of the field is `PERIODIC`"]
    #[inline(always)]
    pub fn is_periodic(&self) -> bool {
        **self == TIMER_MODE_A::PERIODIC
    }
}
impl core::ops::Deref for TIMER_MODE_R {
    type Target = crate::FieldReader<bool, TIMER_MODE_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `timer_mode` writer - Timer mode control"]
pub struct TIMER_MODE_W<'a> {
    w: &'a mut W,
}
impl<'a> TIMER_MODE_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: TIMER_MODE_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "free mode."]
    #[inline(always)]
    pub fn free(self) -> &'a mut W {
        self.variant(TIMER_MODE_A::FREE)
    }
    #[doc = "periodic mode"]
    #[inline(always)]
    pub fn periodic(self) -> &'a mut W {
        self.variant(TIMER_MODE_A::PERIODIC)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
        self.w
    }
}
#[doc = "Timer enable.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TIMER_EN_A {
    #[doc = "0: disabled."]
    DISABLED = 0,
    #[doc = "1: enabled."]
    ENABLED = 1,
}
impl From<TIMER_EN_A> for bool {
    #[inline(always)]
    fn from(variant: TIMER_EN_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `timer_en` reader - Timer enable."]
pub struct TIMER_EN_R(crate::FieldReader<bool, TIMER_EN_A>);
impl TIMER_EN_R {
    pub(crate) fn new(bits: bool) -> Self {
        TIMER_EN_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> TIMER_EN_A {
        match self.bits {
            false => TIMER_EN_A::DISABLED,
            true => TIMER_EN_A::ENABLED,
        }
    }
    #[doc = "Checks if the value of the field is `DISABLED`"]
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        **self == TIMER_EN_A::DISABLED
    }
    #[doc = "Checks if the value of the field is `ENABLED`"]
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        **self == TIMER_EN_A::ENABLED
    }
}
impl core::ops::Deref for TIMER_EN_R {
    type Target = crate::FieldReader<bool, TIMER_EN_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `timer_en` writer - Timer enable."]
pub struct TIMER_EN_W<'a> {
    w: &'a mut W,
}
impl<'a> TIMER_EN_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: TIMER_EN_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "disabled."]
    #[inline(always)]
    pub fn disabled(self) -> &'a mut W {
        self.variant(TIMER_EN_A::DISABLED)
    }
    #[doc = "enabled."]
    #[inline(always)]
    pub fn enabled(self) -> &'a mut W {
        self.variant(TIMER_EN_A::ENABLED)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
        self.w
    }
}
impl R {
    #[doc = "Bit 3 - Timer lock control."]
    #[inline(always)]
    pub fn timer_lock(&self) -> TIMER_LOCK_R {
        TIMER_LOCK_R::new(((self.bits >> 3) & 0x01) != 0)
    }
    #[doc = "Bit 2 - Timer interrupt mask."]
    #[inline(always)]
    pub fn timer_int_mask(&self) -> TIMER_INT_MASK_R {
        TIMER_INT_MASK_R::new(((self.bits >> 2) & 0x01) != 0)
    }
    #[doc = "Bit 1 - Timer mode control"]
    #[inline(always)]
    pub fn timer_mode(&self) -> TIMER_MODE_R {
        TIMER_MODE_R::new(((self.bits >> 1) & 0x01) != 0)
    }
    #[doc = "Bit 0 - Timer enable."]
    #[inline(always)]
    pub fn timer_en(&self) -> TIMER_EN_R {
        TIMER_EN_R::new((self.bits & 0x01) != 0)
    }
}
impl W {
    #[doc = "Bit 3 - Timer lock control."]
    #[inline(always)]
    pub fn timer_lock(&mut self) -> TIMER_LOCK_W {
        TIMER_LOCK_W { w: self }
    }
    #[doc = "Bit 2 - Timer interrupt mask."]
    #[inline(always)]
    pub fn timer_int_mask(&mut self) -> TIMER_INT_MASK_W {
        TIMER_INT_MASK_W { w: self }
    }
    #[doc = "Bit 1 - Timer mode control"]
    #[inline(always)]
    pub fn timer_mode(&mut self) -> TIMER_MODE_W {
        TIMER_MODE_W { w: self }
    }
    #[doc = "Bit 0 - Timer enable."]
    #[inline(always)]
    pub fn timer_en(&mut self) -> TIMER_EN_W {
        TIMER_EN_W { w: self }
    }
    #[doc = "Writes raw bits to the register."]
    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "TIMER_CONTROLREG is the timer control register.\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [control](index.html) module"]
pub struct CONTROL_SPEC;
impl crate::RegisterSpec for CONTROL_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [control::R](R) reader structure"]
impl crate::Readable for CONTROL_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [control::W](W) writer structure"]
impl crate::Writable for CONTROL_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets control to value 0"]
impl crate::Resettable for CONTROL_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
